﻿#include "BPerjanus.h"
#include "ui_BPerjanus.h"
#include <bperutil/sys/BPerHttp.h>
#include <bperutil/sys/BPerUrl.h>
#include <bperutil/sys/BPerLog.h>
BPerJanus::BPerJanus(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::BPerJanus)
{
    ui->setupUi(this);
}

BPerJanus::~BPerJanus()
{
    delete ui;
}

void BPerJanus::on_m_b_rec_clicked()
{
    BPerUrlData urlData;
    memset(&urlData,0,sizeof(BPerUrlData));
    char* remoteSdp=(char*)bPer_calloc(1,1024);

    if(bPer_http_url_parse(BPer_IpFamilyType_IPV4,ui->m_url->text().toLatin1().data(),&urlData)!=BPer_Ok){
        ui->m_retInfo->setText("url format error!");
         bPer_free(remoteSdp);
        return;
    }

    int32_t err=bPer_http_post(BPerFalse,BPer_IpFamilyType_IPV4,remoteSdp,urlData.server,
            urlData.port, (char*)"whip/create", (uint8_t*)ui->m_data->text().toLatin1().data(), bPer_strlen(ui->m_data->text().toLatin1().data()));
    char* endp=bPer_strstr(remoteSdp,"\r\n\r\n");
    ui->m_retInfo->setText(endp);
     bPer_free(remoteSdp);
}

void BPerJanus::on_m_b_rec_2_clicked()
{
    this->hide();
}
